//package com.org.config;
//
//import org.quartz.CronScheduleBuilder;
//import org.quartz.JobBuilder;
//import org.quartz.JobDetail;
//import org.quartz.Scheduler;
//import org.quartz.Trigger;
//import org.quartz.TriggerBuilder;
//import org.quartz.TriggerKey;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.ApplicationListener;
//import org.springframework.context.event.ContextRefreshedEvent;
//import org.springframework.stereotype.Component;
//
///**
// * author: vane.Q
// * device: mac
// * date: 2022/10/29 21:01
// * 监听spring启动的的监听器，测试类
// */
//@Component
//public class StartApplicationListener implements ApplicationListener<ContextRefreshedEvent> {
//
//    @Autowired
//    private Scheduler scheduler;
//
//    @Override
//    public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
//        try {
////            TriggerKey triggerKey = TriggerKey.triggerKey("trigger4", "group1");
////            Trigger trigger = scheduler.getTrigger(triggerKey);
////            if (trigger == null) {
////                trigger = TriggerBuilder.newTrigger()
////                        .withIdentity(triggerKey)
////                        .withSchedule(CronScheduleBuilder.cronSchedule("0/10 * * * * ?"))
////                        .withDescription("这是trigger4")
////                        .startNow()
////                        .build();
////                // 一个jobDetail在一个实例上，每个节点跑一个job，比如有两个jobDetail,项目启动了两个，会自动分配
////                JobDetail jobDetail = JobBuilder.newJob(QuartzJob.class)
////                        .withIdentity("job4", "group2")
////                        .withDescription("这是job4")
////                        .build();
////                scheduler.scheduleJob(jobDetail, trigger);
////            }
//
////                TriggerKey triggerKey = TriggerKey.triggerKey("trigger2", "group2");
////                Trigger trigger = scheduler.getTrigger(triggerKey);
////                if (trigger == null) {
////                    trigger = TriggerBuilder.newTrigger()
////                            .withIdentity(triggerKey)
////                            .withSchedule(CronScheduleBuilder.cronSchedule("0/10 * * * * ?"))
////                            .startNow()
////                            .build();
////                    // 一个jobDetail在一个节点上
////                    JobDetail jobDetail = JobBuilder.newJob(QuartzJob.class)
////                            .withIdentity("job2", "group2")
////                            .build();
////                    scheduler.scheduleJob(jobDetail, trigger);
////
////                scheduler.start();
////                }
////            TriggerKey triggerKey = TriggerKey.triggerKey("trigger1", "group2");
////            Trigger trigger = scheduler.getTrigger(triggerKey);
////            if (trigger == null) {
////                trigger = TriggerBuilder.newTrigger()
////                        .withIdentity(triggerKey)
////                        .withSchedule(CronScheduleBuilder.cronSchedule("0/20 * * * * ?"))
////                        .startNow()
////                        .build();
////                // 一个jobDetail在一个实例上，每个节点跑一个job，比如有两个jobDetail,项目启动了两个，会自动分配
////                JobDetail jobDetail = JobBuilder.newJob(QuartzJob.class)
////                        .withIdentity("job3", "group2")
////                        .build();
////                scheduler.scheduleJob(jobDetail, trigger);
////            }
////            scheduler.start();
//
////            TriggerKey triggerKey = TriggerKey.triggerKey("trigger1", "trigger第一组");
////            Trigger trigger = scheduler.getTrigger(triggerKey);
////            if (trigger == null) {
////                trigger = TriggerBuilder.newTrigger()
////                        .withIdentity(triggerKey)
////                        .withSchedule(CronScheduleBuilder.cronSchedule("0/20 * * * * ?"))
////                        .startNow()
////                        .build();
////                // 一个jobDetail在一个实例上，每个节点跑一个job，比如有两个jobDetail,项目启动了两个，会自动分配
////                JobDetail jobDetail = JobBuilder.newJob(QuartzJob.class)
////                        .withIdentity("job1", "job第一组")
////                        .build();
////                scheduler.scheduleJob(jobDetail, trigger);
////            }
////            scheduler.start();
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//
//    }
//}
